<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		.box{
			width: 200px;
			height: 200px;
			background: red;
		}
		@keyframes demo1{
			from{
				transform: scale(1);
			}
			to{
				transform: scale(2);
			}
		}
		@keyframes demo2{
			from{
				transform: scale(2);
			}
			to{
				transform: scale(1);
			}
		}
	</style>
</head>
<body>
		<div class="box"></div>
		
		<script type="text/javascript">
			let box = document.querySelector('.box');
			box.onmouseover=function(){
				box.style.animation="demo1 2s forwards"
			}
			box.onmouseout=function(){
				box.style.animation="demo2 2s forwards"
			}
		</script>
</body>
</html>